package com.jbp.controller;

import com.jbp.model.AppConfig;
import com.jbp.service.AppConfigService;
import com.jbp.utils.R;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * 应用设置(AppConfig)表控制层
 * @author cc
 * @since 2020-07-04 23:42:42
 */
@Api(tags ="APP接口--应用配置" ,hidden = true)
@ApiIgnore
@RestController
@RequestMapping("appConfig")
public class AppConfigController {
    @Autowired
    private AppConfigService appConfigService;
    
    @ApiOperation(value="获取参数", hidden = true)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "key",value = "advancedLottery 高级蛋配置  1 开启 0关闭"),
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = AppConfig.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @GetMapping("/getParam")
    public R getParam(@RequestParam("key") String key){
        AppConfig config = appConfigService.getByKey(key);
        return R.ok(config);
    }

    @GetMapping("/getParams")
    public R getParams(){
        List<AppConfig> appConfigList = appConfigService.appConfigList();
        return R.ok().put("data", appConfigList);
    }



}